#! /usr/bin/perl -w
#------------------------------------------------
# Author:    kvkrishna
# Created:   Fri May 13 16:21:35 IST 2011
# File Name: SampleRun
# 
# 
# 
# 
#------------------------------------------------
sub HELP ;
#------------------------------------------------------------------------------------------------ MAIN
while ( scalar @ARGV > 0 ) {
        if      ( $ARGV[0] eq "-n"            ) { shift; $TARGET   = shift; next; }
        elsif   ( $ARGV[0] eq "-seed"         ) { shift; $SEED     = shift; next; }
        elsif   ( $ARGV[0] eq "-testcase"     ) { shift; $TESTCASE = shift; next; }
        elsif   ( $ARGV[0] eq "-h" or "-help" ) { HELP ; exit 0; }
        else    { print "Invalid Option found...\nTry '-h' or '-help' to know valid options"; }
}

print "ASMWORK variable not defined, Try sourcing setup file\n" and die if not defined $ENV{ASMWORK} ;
$TESTCASE = 'simple_test'                if not defined $TESTCASE ;
$TARGET   = 1                            if not defined $TARGET or $TARGET < 1 ;
$SEED     = 10000000 + int rand 89999999 if not defined $SEED or $TARGET > 1 ;
while ( $TARGET-- > 0 ) {
        system "make -f $ENV{ASMWORK}/Makefile ASM TEST=$TESTCASE SEED=$SEED" ;
        $SEED     = 10000000 + int rand 89999999 ;
}
#------------------------------------------------------------------------------------------------ HELP
sub HELP {
        print "\nHelp" ;
        print "\n" ;
        exit 0 ;
}
